@extends('frontend/layouts/flaty_to_bootstrap')

@section('content.title')
<h1><i class="icon-list"></i> Summary</h1>
@stop

@section('content.breadcrumb.inner')
<li><a href="{{ route('home') }}"><i class="icon-home"></i> Dashboard</a><span class="divider"><i class="icon-angle-right"></i></span></li>
<li class="active">Summary</li>
@stop

@section('content.main')

<div class="row-fluid">
    <div class="span6">
        <div class="box box-gray">
            <div class="box-title">
                <h3><i class="icon-table"></i> Filter option</h3>
                <div class="box-tool">
                    <a data-action="collapse" href="#"><i class="icon-chevron-down"></i></a>
                </div>
            </div>
            <div class="box-content">
                <form action="{{ route('car_balance.main.summary') }}" class="form-horizontal" method="post">
                    <div class="control-group">
                        <label class="control-label">Purchase date</label>
                        <div class="controls">
                            <span >
                                <i class="icon-calendar"></i>
                                &nbsp;
                                <input id="form-date-range" type="text" name="purchase_date" id="daterange" value="{{ count($filters['purchase_date']) > 1 ? $filters['purchase_date'][0] .' to '.$filters['purchase_date'][1] : '' }}"/>
                            </span>
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">Hudaldan avagch</label>
                        <div class="controls">
                            {{ Form::select('customer_id', $customer_list, $filters['customer_id']) }}
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">Service company</label>
                        <div class="controls">
                            {{ Form::select('service_company_id', $service_company_list, $filters['service_company_id']) }}
                        </div>
                    </div>

                    {{ Form::token() }}
                    <input class="btn btn-primary" type="submit" value="apply filter"/>
                </form>
            </div>
        </div>
    </div>
    <div class="span6">
        <div class="box box-blue">
            <div class="box-title">
                <h3><i class="icon-table"></i> Result details</h3>
                <div class="box-tool">
                    <a data-action="collapse" href="#"><i class="icon-chevron-down"></i></a>
                </div>
            </div>
            <div class="box-content">
                <ul class="weekly-stats">
                    <li>Total purchase cars: <span class="value">{{ $cars->count() }}</span></li>
                    <li>Total parts: <span class="value">0</span></li>
                    <li>Total ems: <span class="value">{{ $ems_count }}</span></li>
                    <li>Total money transfers: <span class="value">0</span></li>
                </ul>
            </div>
        </div>
    </div>
</div>

@if ($cars->count())
{{-- SUMMARY --}}
<div class="row-fluid">
    <div class="span12">
        <div class="box box-orange">
            <div class="box-title">
                <h3><i class="icon-table"></i> PURCHASE CAR SUMMARY (COST)</h3>
                <div class="box-tool">
                    <a data-action="collapse" href="#"><i class="icon-chevron-up"></i></a>
                </div>
            </div>
            <div class="box-content">
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th>Purchase price</th>
                        <th>Consumption tax</th>
                        <th>Recycle fee</th>
                        <th>Car certification</th>
                        <th>Auction commission</th>
                        <th>Transport fee japan</th>
                        <th>Burtgel solih</th>
                        <th>Export erasure</th>
                        <th>Car tax cancel</th>
                        <th>Send export erasure to transport company</th>
                        <th>Fax export erasure to auction</th>
                        <th>Mail export erasure to nmc</th>
                        <th>Car liability insurance cancel</th>
                        <th>Recycle</th>
                        <th>TOTAL</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td>{{ $summary_totals['t_purchase_price'] }}</td>
                        <td>{{ $summary_totals['t_consumption_tax'] }}</td>
                        <td>{{ $summary_totals['t_recycle_fee'] }}</td>
                        <td>{{ $summary_totals['t_car_certification'] }}</td>
                        <td>{{ $summary_totals['t_auction_commission'] }}</td>
                        <td>{{ $summary_totals['t_transport_fee_japan'] }}</td>
                        <td>{{ $summary_totals['t_burtgel_solih'] }}</td>
                        <td>{{ $summary_totals['t_export_erasure'] }}</td>
                        <td>{{ $summary_totals['t_car_tax_cancel'] }}</td>
                        <td>{{ $summary_totals['t_send_export_erasure_to_transport_company'] }}</td>
                        <td>{{ $summary_totals['t_fax_export_erasure_to_auction'] }}</td>
                        <td>{{ $summary_totals['t_mail_export_erasure_to_nmc'] }}</td>
                        <td>{{ $summary_totals['t_car_liability_insurance_cancel'] }}</td>
                        <td>{{ $summary_totals['t_recycle'] }}</td>
                        <td><b class="light-red">{{ $summary_totals['t_total'] }}</b></td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="box box-orange">
            <div class="box-title">
                <h3><i class="icon-table"></i> PURCHASE CAR SUMMARY (PROFIT)</h3>
                <div class="box-tool">
                    <a data-action="collapse" href="#"><i class="icon-chevron-up"></i></a>
                </div>
            </div>
            <div class="box-content">
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th>NMH Commission</th>
                        <th>Consumption tax</th>
                        <th>Recycle fee</th>
                        <th>Car certification</th>
                        <th>TOTAL</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td>{{ $summary_totals['t_nmh_commission_p'] }}</td>
                        <td>{{ $summary_totals['t_consumption_tax_p'] }}</td>
                        <td>{{ $summary_totals['t_recycle_fee_p'] }}</td>
                        <td>{{ $summary_totals['t_car_certification_p'] }}</td>
                        <td><strong class="light-green">{{ $summary_totals['t_total_p'] }}</strong></td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
@if($filters['service_company_id'] == 0 && $filters['customer_id'] == 0)
<div class="row">
    <div class="span6">
        <div class="box box-green">
            <div class="box-title">
                <h3><i class="icon-table"></i> EMS SUMMARY</h3>
                <div class="box-tool">
                    <a data-action="collapse" href="#"><i class="icon-chevron-up"></i></a>
                </div>
            </div>
            <div class="box-content">
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th>TOTAL (fee japan)</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td><strong class="light-green">{{ is_null($ems_sum) ? 0 : $ems_sum }}</strong></td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
@endif


@else
    There are no data
@endif

@stop


@section('stylesheets.more')
<link rel="stylesheet" type="text/css" href={{ asset('assets/bootstrap-daterangepicker/daterangepicker.css') }} />
@stop

@section('javascripts.more')
<!--page specific plugin scripts-->
<script type="text/javascript" src={{ asset('assets/bootstrap-daterangepicker/date.js') }} ></script>
<script type="text/javascript" src={{ asset('assets/bootstrap-daterangepicker/daterangepicker.js') }}></script>
@stop